package com.coocaa.x.service.litepush;

import android.content.Context;
import android.content.Intent;

import com.coocaa.x.framework.utils.Android;

/**
 * Created by lu on 15-7-29.
 */


public class LitePushServiceStub implements CoocaaPUSH.ICoocaaPUSH {

    private Context mContext = null;

    public LitePushServiceStub(Context context) {
        mContext = context;
        try {
            Boolean useCoocaaPush = true;
            try {
                useCoocaaPush = (Boolean) Android.getMetaData(context, context.getPackageName(), "enable_coocaa_push");

            } catch (Exception e) {
                e.printStackTrace();
            }
            if (useCoocaaPush)
                CoocaaPUSH.init(this);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onMSG(String msg) {
        Intent intent = new Intent(LitePush.LITEPUSH_MSG_ACTION);
        intent.putExtra(LitePush.LITEPUSH_MSG_KEY, msg);
        mContext.sendBroadcast(intent);
    }

    @Override
    public void onPushId(String pushId) {
        Intent intent = new Intent(LitePush.LITEPUSH_MSG_PUSHID);
        intent.putExtra(LitePush.LITEPUSH_MSG_KEY, pushId);
        mContext.sendBroadcast(intent);
    }
}
